package chen.yi.component.code.generator.config;

import cn.hutool.core.util.StrUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * 基础信息配置
 * @author huat
 **/
@ConfigurationProperties("chen-yi.code.generator")
@Setter
public class BaseInfoConfig {
    /**
     * 表名前缀
     */
    @Getter
    private String tablePrefix;
    /**
     * 作者
     */
    private String authorName;
    /**
     * 实体类所在包前缀
     */
    private String entityPackage;
    /**
     * mapper层所在包
     */
    private String mapperPackage;
    /**
     * 业务层所在包
     */
    private String servicePackage;
    /**
     * 控制层所在包
     */
    private String controllerPackage;

    public String getEntityPackage() {
        if(StrUtil.isBlank(entityPackage)){
            return "chen.yi.mapper.po";
        }
        return entityPackage;
    }

    public String getAuthorName() {
        if(StrUtil.isBlank(authorName)){
            return "huat";
        }
        return authorName;
    }

    public String getMapperPackage() {
        if(StrUtil.isBlank(mapperPackage)){
            return "chen.yi.mapper.mapper";
        }
        return mapperPackage;
    }

    public String getServicePackage() {
        if(StrUtil.isBlank(servicePackage)){
            return "chen.yi.service.service";
        }
        return servicePackage;
    }

    public String getControllerPackage() {
        if(StrUtil.isBlank(controllerPackage)){
            return "chen.yi.web.controller";
        }
        return controllerPackage;
    }
}
